/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author edgar
 */
@Entity
@Table(name = "notas_credito_cabecera")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "NotasCreditoCabecera.findAll", query = "SELECT n FROM NotasCreditoCabecera n"),
    @NamedQuery(name = "NotasCreditoCabecera.findByNroNota", query = "SELECT n FROM NotasCreditoCabecera n WHERE n.notasCreditoCabeceraPK.nroNota = :nroNota"),
    @NamedQuery(name = "NotasCreditoCabecera.findByNroFactura", query = "SELECT n FROM NotasCreditoCabecera n WHERE n.notasCreditoCabeceraPK.nroFactura = :nroFactura"),
    @NamedQuery(name = "NotasCreditoCabecera.findByFecha", query = "SELECT n FROM NotasCreditoCabecera n WHERE n.fecha = :fecha")})
public class NotasCreditoCabecera implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected NotasCreditoCabeceraPK notasCreditoCabeceraPK;
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "notasCreditoCabecera")
    private List<NotasCreditoDetalle> notasCreditoDetalleList;

    public NotasCreditoCabecera() {
    }

    public NotasCreditoCabecera(NotasCreditoCabeceraPK notasCreditoCabeceraPK) {
        this.notasCreditoCabeceraPK = notasCreditoCabeceraPK;
    }

    public NotasCreditoCabecera(int nroNota, int nroFactura) {
        this.notasCreditoCabeceraPK = new NotasCreditoCabeceraPK(nroNota, nroFactura);
    }

    public NotasCreditoCabeceraPK getNotasCreditoCabeceraPK() {
        return notasCreditoCabeceraPK;
    }

    public void setNotasCreditoCabeceraPK(NotasCreditoCabeceraPK notasCreditoCabeceraPK) {
        this.notasCreditoCabeceraPK = notasCreditoCabeceraPK;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    @XmlTransient
    public List<NotasCreditoDetalle> getNotasCreditoDetalleList() {
        return notasCreditoDetalleList;
    }

    public void setNotasCreditoDetalleList(List<NotasCreditoDetalle> notasCreditoDetalleList) {
        this.notasCreditoDetalleList = notasCreditoDetalleList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (notasCreditoCabeceraPK != null ? notasCreditoCabeceraPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof NotasCreditoCabecera)) {
            return false;
        }
        NotasCreditoCabecera other = (NotasCreditoCabecera) object;
        if ((this.notasCreditoCabeceraPK == null && other.notasCreditoCabeceraPK != null) || (this.notasCreditoCabeceraPK != null && !this.notasCreditoCabeceraPK.equals(other.notasCreditoCabeceraPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.NotasCreditoCabecera[ notasCreditoCabeceraPK=" + notasCreditoCabeceraPK + " ]";
    }
    
}
